var ordersService = easyMe.import("public/javascripts/service/ordersService.js");
var cx = easyMe.import("public/common/classNames.js");
var MyInputComponent = easyMe.import("public/javascripts/widget/myInput/myInput.js");
var selectFactory = easyMe.import("public/javascripts/widget/select/select.js");

var AddressComponent = React.createClass({
    componentDidMount: function () {
        var _this = this;

        //首先获取产品组GroupRootId
        if(_this.state.info.productId ){
            
            _this.getProductGroup(_this.state.info.productId, function (productGroupRootId) {

                if (_this.state.info.from == 'product') {    //从下单界面过来，初始化可用地址信息。
                    _this.setProDefAddress(_this.state.info.productUid, productGroupRootId);
                } else if (_this.state.info.from == 'feeTrial') {    //从运费试算界面过来，初始化可用地址信息。
                    _this.setFeeDefAddress(_this.state.info.productId, productGroupRootId);
                } else if (_this.state.info.from == 'orders') {    //从订单列表过来的。

                }else if(_this.state.info.from == 'highVolumeOrders') { //从批量下单过来
                   // _this.checkHighVolumeData();
                }
            });
        }


        //获取产品主服务或者必选服务有揽收服务，并且可选服务是否为揽收
        _this.getReceived(_this.state.info.productUid, function(){
            if(_this.state.info.from == 'highVolumeOrders'){
                _this.checkHighVolumeData();
            }

        });
    },
    checkHighVolumeData:function () {

        var self = this;
        var errorDtoMap = self.state.info.errorDtoMap;
        //发件人地址
        if(errorDtoMap === null){
            return;
        }

        if(errorDtoMap.fromName){
            self.refs["fromName"].showErrorMsg(errorDtoMap.fromName.message);
        }
        if(errorDtoMap.fromPostcode){
            self.refs["data.fromAddress.postcode"].showErrorMsg(errorDtoMap.fromPostcode.message);
        }
        if(errorDtoMap.fromPhone){
            self.refs["fromPhone"].showErrorMsg(errorDtoMap.fromPhone.message);
        }
        if(errorDtoMap.fromTelephone){
            self.refs["fromTelephone"].showErrorMsg(errorDtoMap.fromTelephone.message);
        }
        if(errorDtoMap.fromEmail){
            self.refs["data.fromAddress.email"].showErrorMsg(errorDtoMap.fromEmail.message);
        }


        //收件人地址
        if(errorDtoMap.toName){
            self.refs["toName"].showErrorMsg(errorDtoMap.toName.message);
        }
        if(errorDtoMap.toPostcode){
            self.refs["data.toAddress.postcode"].showErrorMsg(errorDtoMap.toPostcode.message);
        }
        if(errorDtoMap.toPhone){
            self.refs["toPhone"].showErrorMsg(errorDtoMap.toPhone.message);
        }
        if(errorDtoMap.toTelephone){
            self.refs["toTelephone"].showErrorMsg(errorDtoMap.toTelephone.message);
        }
        if(errorDtoMap.toEmail){
            self.refs["data.toAddress.email"].showErrorMsg(errorDtoMap.toEmail.message);
        }

        //提货地址

        if(errorDtoMap.fetchName){
            self.refs["fetchName"].showErrorMsg(errorDtoMap.fetchName.message);
        }
        if(errorDtoMap.fetchPostcode){
            self.refs["data.fetchAddress.postcode"].showErrorMsg(errorDtoMap.fetchPostcode.message);
        }
        if(errorDtoMap.fetchPhone){
            self.refs["fetchPhone"].showErrorMsg(errorDtoMap.fetchPhone.message);
        }
        if(errorDtoMap.fetchTelephone){
            self.refs["fetchTelephone"].showErrorMsg(errorDtoMap.fetchTelephone.message);
        }
        if(errorDtoMap.fetchEmail){
            self.refs["data.fetchAddress.email"].showErrorMsg(errorDtoMap.fetchEmail.message);
        }

        //集体校验地址,同提交的
        self.checkAddr();

    },
    // clearAddrErrorTips:function (addr) {
    //     var self = this;
    //     if(addr && self.refs[addr]){
    //         self.refs[addr].hideErrorMsg();
    //     }
    // },
    clearAddrErrorTipsByType:function(type){
        var self = this;

        if(!type) return;


        if( self.refs['data.'+ type +'.countryName']){
            self.refs['data.'+ type +'.countryName'].hideErrorMsg();
        }
        if( self.refs['data.'+ type +'.transportName']){
            self.refs['data.'+ type +'.transportName'].hideErrorMsg();
        }
        if( self.refs['data.'+ type +'.provinceName']){
            self.refs['data.'+ type +'.provinceName'].hideErrorMsg();
        }
        if( self.refs['data.'+ type +'.cityName']){
            self.refs['data.'+ type +'.cityName'].hideErrorMsg();
        }
        if( self.refs['data.'+ type +'.districtName']){
            self.refs['data.'+ type +'.districtName'].hideErrorMsg();
        }
        if( self.refs['data.'+ type +'.streetName']){
            self.refs['data.'+ type +'.streetName'].hideErrorMsg();
        }
        if( self.refs['data.'+ type +'.address']){
            self.refs['data.'+ type +'.address'].hideErrorMsg();
        }

    },
    checkAddr:function () {

        var _this = this;
        var self = this;
        var errorDtoMap = self.state.info.errorDtoMap;

        var val = _this.state.data;

        var isSeaAir = _this.state.info.productGroupRootId == 11 ? false : true,
            isHaveReceive = _this.state.info.isHaveReceive ? true : false;


        //校验国家

        // 目前的策略是地址部分有一个错误，包括下面三种 1 地址为空 2 地址错误 3 地址不在范围内 整体标红
        if(errorDtoMap.fromAddress){ //这个是整体的地址错误：不在产品范围之内
            self.refs["data.fromAddress.countryName"].showErrorMsg(errorDtoMap.fromAddress.message);
        }

        if(errorDtoMap.toAddress){ //这个是整体的地址错误：不在产品范围之内
            self.refs["data.toAddress.countryName"].showErrorMsg(errorDtoMap.toAddress.message);
        }

        if (isHaveReceive) {
            if(errorDtoMap.fetchAddress){ //这个是整体的地址错误：不在产品范围之内
                self.refs["data.fetchAddress.countryName"].showErrorMsg(errorDtoMap.fetchAddress.message);
            }
        }
        if (isSeaAir) {    // 海运或空运 海运或者空运的地址对应的是District这一层

            if(errorDtoMap.fromAddress ){
                self.refs["data.fromAddress.transportName"].showErrorMsg('');
            }

            if(errorDtoMap.toAddress ){
                self.refs["data.toAddress.transportName"].showErrorMsg('');
            }

        } else {

            if(errorDtoMap.fromAddress ){ // 详细地址错误
                self.refs["data.fromAddress.address"].showErrorMsg('');
            }

            if(errorDtoMap.toAddress ){
                self.refs["data.toAddress.address"].showErrorMsg('');
            }

            if (val.fromAddress.countryCode == 'CN') {

                if(errorDtoMap.fromAddress ){
                    self.refs["data.fromAddress.provinceName"].showErrorMsg('');
                    self.refs["data.fromAddress.cityName"].showErrorMsg('');
                    self.refs["data.fromAddress.districtName"].showErrorMsg('');
                    self.refs["data.fromAddress.streetName"].showErrorMsg('');
                }

            } else {

                if(errorDtoMap.fromAddress ){
                    self.refs["data.fromAddress.cityName"].showErrorMsg('');
                }
            }
            if (val.toAddress.countryCode == 'CN') {

                if(errorDtoMap.toAddress ){
                    self.refs["data.toAddress.provinceName"].showErrorMsg('');
                    self.refs["data.toAddress.cityName"].showErrorMsg('');
                    self.refs["data.toAddress.districtName"].showErrorMsg('');
                    self.refs["data.toAddress.streetName"].showErrorMsg('');
                }

            } else {

                if(errorDtoMap.toAddress ){
                    self.refs["data.toAddress.cityName"].showErrorMsg('');
                }
            }
        }

        if (isHaveReceive) {

            if(errorDtoMap.fetchAddress ){
                self.refs["data.fetchAddress.address"].showErrorMsg('');
            }

            if (val.fetchAddress.countryCode == 'CN') {

                if(errorDtoMap.fetchAddress ){
                    self.refs["data.fetchAddress.provinceName"].showErrorMsg('');
                    self.refs["data.fetchAddress.cityName"].showErrorMsg('');
                    self.refs["data.fetchAddress.districtName"].showErrorMsg('');
                    self.refs["data.fetchAddress.streetName"].showErrorMsg('');
                }

            } else {

                if(errorDtoMap.fetchAddress ){
                    self.refs["data.fetchAddress.cityName"].showErrorMsg('');
                }
            }
        }

    },
    clearErrorTipsByAddrType:function (addr,addrType) {
        var self = this;

        //清除后台来的所有错误
        if(self.refs["data."+addr+".countryName"]){
            self.refs["data."+addr+".countryName"].hideErrorMsg();
        }

        if(self.refs["data."+addr+".transportName"]){
            self.refs["data."+addr+".transportName"].hideErrorMsg();
        }

        if(self.refs["data."+addr+".address"]) {
            self.refs["data."+addr+".address"].hideErrorMsg();
        }

        if(self.refs["data."+addr+".provinceName"]) {
            self.refs["data."+addr+".provinceName"].hideErrorMsg();
        }
        if(self.refs["data."+addr+".cityName"]) {
            self.refs["data."+addr+".cityName"].hideErrorMsg();
        }
        if(self.refs["data."+addr+".districtName"]) {
            self.refs["data."+addr+".districtName"].hideErrorMsg();
        }
        if(self.refs["data."+addr+".streetName"]) {
            self.refs["data."+addr+".streetName"].hideErrorMsg();
        }
        if(self.refs["data."+addr+".email"]) {
            self.refs["data."+addr+".email"].hideErrorMsg();
        }
        if(self.refs["data."+addr+".postcode"]) {
            self.refs["data."+addr+".postcode"].hideErrorMsg();
        }

        if(addrType === 1){  //发货地址
            if(self.refs["fromName"]) {
                self.refs["fromName"].hideErrorMsg();
            }
            if(self.refs["fromPhone"]) {
                self.refs["fromPhone"].hideErrorMsg();
            }
            if(self.refs["fromTelephone"]) {
                self.refs["fromTelephone"].hideErrorMsg();
            }
        }

        if(addrType === 2){
            if(self.refs["toName"]) {
                self.refs["toName"].hideErrorMsg();
            }
            if(self.refs["toPhone"]) {
                self.refs["toPhone"].hideErrorMsg();
            }
            if(self.refs["toTelephone"]) {
                self.refs["toTelephone"].hideErrorMsg();
            }
        }

        if(addrType === 3){
            if(self.refs["fetchName"]) {
                self.refs["fetchName"].hideErrorMsg();
            }
            if(self.refs["fetchPhone"]) {
                self.refs["fetchPhone"].hideErrorMsg();
            }
            if(self.refs["fetchTelephone"]) {
                self.refs["fetchTelephone"].hideErrorMsg();
            }
        }


    },
    receiveMsg: function (data) {
        var _this = this;

        $('#fromAddress-box input.required').removeClass('required');
        $('#toAddress-box input.required').removeClass('required');
        $('#fetchAddress-box input.required').removeClass('required');

        if (data.change == 'product') {    //更换产品
            var productId = data.data.id,
                productUid = data.data.uid;

            //已选可选服务清空
            _this.state.data.optionalService = [];

            _this.state.info.productId = productId;
            _this.state.info.productUid = productUid;
            _this.setState();

            _this.getReceived(productUid);    //产品是否包含揽收服务。

            _this.getProductGroup(productId, function (productGroupRootId) {
                _this.setProDefAddress(productUid, productGroupRootId);    //更新可用地址
            });

        } else if (data.change == 'service') {    //勾选服务
            _this.state.data.optionalService = data.data;
            _this.setState();

            _this.getReceived(_this.state.info.productUid, function(isHaveReceive){
                if(isHaveReceive){    //包含揽收，并且揽收为空
                    if(!_this.state.data.fetchAddress || JSON.stringify(_this.state.data.fetchAddress) == '{}'){
                        var config = {
                            'urlParams': {
                                'type': 3,
                                'transportType': 11,
                                'uId': _this.state.info.productUid
                            }
                        };
                        ordersService.getAddress(config, function (res) {
                            if (res.errorCode === 0) {
                                var pickMap = {}, fetchSynShow = true, pickNum = res.data.pick.length;
                                res.data.pick.forEach(function (item, index) {
                                    if (item.enable && item.isDefault) {
                                        pickMap = item;
                                    }
                                    if (pickMap.name) {
                                        _this.state.data.fetchAddress = $.extend({}, pickMap);
                                        _this.state.data.fetchAddress.countryName += '(' + _this.state.data.fetchAddress.countryCode + ')';
                                    } else {
                                        if (pickNum == 10) {
                                            $('#fetch-checkbox').addClass('u-checkbox-disabled');
                                        }
                                        for (var i in _this.state.data.fetchAddress) {
                                            _this.state.data.fetchAddress[i] = '';
                                        }
                                        _this.state.data.fetchAddress.transportType = 11;
                                    }

                                    _this.state.data.fetchName = pickMap.name || '';
                                    _this.state.data.fetchPhone = pickMap.phone || '';
                                    _this.state.data.fetchTelephone = pickMap.telPhone || '';
                                });
                                _this.setState();
                            }
                        });
                    }
                }
            });
        }
    },
    getInitialState: function () {
        return this.props ? this.props : {};
    },
    setFeeDefAddress: function (productId, productGroupRootId) {
        var _this = this;

        var data = JSON.parse(localStorage.getItem("feeTrialData"));
        _this.state.data.fromAddress = $.extend({}, data.fromAddress);
        _this.state.data.toAddress = $.extend({}, data.endAddress);

        if (data.fromAddress.countryCode) {
            _this.state.data.fromAddress.countryName += '(' + data.fromAddress.countryCode + ')';
        }
        if (data.endAddress.countryCode) {
            _this.state.data.toAddress.countryName += '(' + data.endAddress.countryCode + ')';
        }
        _this.setState();

        if (productGroupRootId != 11) {    //非速递产品
            if (data.fromAddress.countryCode) {
                var config = {
                    'urlParams': {
                        'id': productId,
                        'countryCode': data.fromAddress.countryCode,
                        'cityId': data.fromAddress.cityId || '',
                        'type': 's',
                        'q': '',
                        'pageIndex': 1,
                        'pageSize': 1
                    }
                };
                ordersService.getProductSeaAir(config, function (res) {
                    if (res.errorCode === 0 && res.data && res.data.length) {
                        _this.state.data.fromAddress.transportId = res.data[0].id;
                        if (productGroupRootId == 1) {    //海运
                            _this.state.data.fromAddress.transportName = res.data[0].name + '(' + res.data[0].enName + ')';
                        }else if(productGroupRootId == 6){    //机场
                            _this.state.data.fromAddress.transportName = res.data[0].name + '(' + res.data[0].code + ')';
                        }

                        _this.state.data.fromAddress.transportType = productGroupRootId;
                        _this.setState();
                    }
                });
            }
            if (data.endAddress.countryCode) {
                var config = {
                    'urlParams': {
                        'id': productId,
                        'countryCode': data.endAddress.countryCode,
                        'cityId': data.endAddress.cityId || '',
                        'type': 'e',
                        'q': '',
                        'pageIndex': 1,
                        'pageSize': 1
                    }
                };
                ordersService.getProductSeaAir(config, function (res) {
                    if (res.errorCode === 0 && res.data && res.data.length) {
                        _this.state.data.toAddress.transportId = res.data[0].id;
                        if (productGroupRootId == 1) {    //海运
                            _this.state.data.toAddress.transportName = res.data[0].name + '(' + res.data[0].enName + ')';
                        }else if(productGroupRootId == 6){    //机场
                            _this.state.data.toAddress.transportName = res.data[0].name + '(' + res.data[0].code + ')';
                        }
                        _this.state.data.toAddress.transportType = productGroupRootId;
                        _this.setState();
                    }
                });
            }
        }
    },
    setProDefAddress: function (productUid, productGroupRootId) {   //根据productUid获取可用地址并默认填充上。
        var _this = this;

        var config = {
            'urlParams': {
                'transportType': productGroupRootId,
                'uId': productUid
            }
        };
        ordersService.getAddress(config, function (res) {
            if (res.errorCode === 0) {
                //揽收
                var pickMap = {}, fetchSynShow = true, pickNum = res.data.pick.length;
                if(pickNum){
                    res.data.pick.forEach(function (item, index) {
                        if (item.enable && item.isDefault) {
                            pickMap = item;
                        }
                        if (pickMap.name) {
                            _this.state.data.fetchAddress = $.extend({}, pickMap);
                            _this.state.data.fetchAddress.countryName += '(' + _this.state.data.fetchAddress.countryCode + ')';
                        } else {
                            if (pickNum == 10) {
                                $('#fetch-checkbox').addClass('u-checkbox-disabled');
                            }
                            for (var i in _this.state.data.fetchAddress) {
                                _this.state.data.fetchAddress[i] = '';
                            }
                            _this.state.data.fetchAddress.transportType = productGroupRootId;
                        }

                        _this.state.data.fetchName = pickMap.name || '';
                        _this.state.data.fetchPhone = pickMap.phone || '';
                        _this.state.data.fetchTelephone = pickMap.telPhone || '';
                    });
                }
                else{
                    for (var i in _this.state.data.fetchAddress) {
                        _this.state.data.fetchAddress[i] = '';
                    }

                    _this.state.data.fetchSynShow = true;
                    _this.state.data.fetchName = '';
                    _this.state.data.fetchPhone = '';
                    _this.state.data.fetchTelephone = '';
                    _this.state.data.fetchDetail = '';
                    _this.state.data.fetchAddress.transportType = productGroupRootId;
                    $('#fetchAddress-box input.required').removeClass('required');
                }

                //收件
                var receiverMap = {}, toSynShow = true, receiverNum = res.data.receiver.length;
                if(receiverNum){
                    res.data.receiver.forEach(function (item, index) {
                        if (item.enable && item.isDefault) {
                            receiverMap = item;
                        }
                        if (receiverMap.name) {
                            _this.state.data.toAddress = $.extend({}, receiverMap);
                            _this.state.data.toAddress.countryName += '(' + _this.state.data.toAddress.countryCode + ')';
                            if (productGroupRootId == 1) {
                                _this.state.data.toAddress.transportName += '(' + _this.state.data.toAddress.transportEnglishName + ')';
                            } else if (productGroupRootId == 6) {
                                _this.state.data.toAddress.transportName += '(' + _this.state.data.toAddress.transportCode + ')';
                            }
                        } else {
                            if (receiverNum == 10) {
                                $('#to-checkbox').addClass('u-checkbox-disabled');
                            }
                            for (var i in _this.state.data.toAddress) {
                                _this.state.data.toAddress[i] = '';
                            }
                            _this.state.data.toAddress.transportType = productGroupRootId;
                        }

                        _this.state.data.toName = receiverMap.name || '';
                        _this.state.data.toPhone = receiverMap.phone || '';
                        _this.state.data.toTelephone = receiverMap.telPhone || '';
                    });
                }
                else{
                    for (var i in _this.state.data.toAddress) {
                        _this.state.data.toAddress[i] = '';
                    }

                    _this.state.data.toSynShow = true;
                    _this.state.data.toName = '';
                    _this.state.data.toPhone = '';
                    _this.state.data.toTelephone = '';
                    _this.state.data.toDetail = '';
                    _this.state.data.toAddress.transportType = productGroupRootId;
                    $('#toAddress-box input.required').removeClass('required');
                }

                //发件
                var sendMap = {}, fromSynShow = true, sendNum = res.data.send.length;
                if(sendNum){
                    res.data.send.forEach(function (item, index) {
                        if (item.enable && item.isDefault) {
                            sendMap = item;
                        }
                        if (sendMap.name) {
                            _this.state.data.fromAddress = $.extend({}, sendMap);

                            _this.state.data.fromAddress.countryName += '(' + _this.state.data.fromAddress.countryCode + ')';
                            if (productGroupRootId == 1) {
                                _this.state.data.fromAddress.transportName += '(' + _this.state.data.fromAddress.transportEnglishName + ')';
                            } else if (productGroupRootId == 6) {
                                _this.state.data.fromAddress.transportName += '(' + _this.state.data.fromAddress.transportCode + ')';
                            }
                        } else {
                            if (sendNum == 10) {
                                $('#from-checkbox').addClass('u-checkbox-disabled');
                            }
                            for (var i in _this.state.data.fromAddress) {
                                _this.state.data.fromAddress[i] = '';
                            }
                            _this.state.data.fromAddress.transportType = productGroupRootId;
                        }

                        _this.state.data.fromName = sendMap.name || '';
                        _this.state.data.fromPhone = sendMap.phone || '';
                        _this.state.data.fromTelephone = sendMap.telPhone || '';
                    });
                }
                else{
                    for (var i in _this.state.data.fromAddress) {
                        _this.state.data.fromAddress[i] = '';
                    }

                    _this.state.data.fromSynShow = true;
                    _this.state.data.fromName = '';
                    _this.state.data.fromPhone = '';
                    _this.state.data.fromTelephone = '';
                    _this.state.data.fromDetail = '';
                    _this.state.data.fromAddress.transportType = productGroupRootId;
                    $('#fromAddress-box input.required').removeClass('required');
                }

                //如果为订单草稿状态切换产品时, 如果有默认地址，则不展示更新当前地址或者保存到地址库，否则展示
                if (_this.state.info.oid) {
                    _this.state.data.fromSynShow = fromSynShow;
                    _this.state.data.toSynShow = toSynShow;
                    _this.state.data.fetchSynShow = fetchSynShow;
                }

                _this.setState();
            }
        });
    },
    getProductGroup: function (productId, callback) {   //根据productId获取该产品对应的产品组
        var _this = this;

        var config = {
            'seatParams': {
                'productId': productId
            }
        };
        ordersService.getProGroupRootId(config, function (res) {
            if (res.errorCode === 0) {
                //非海运、空运产品的统一重置为速递。海运：1，空运：6，速递：11
                res.data.productGroupRootId = res.data.productGroupRootId == 1 ? 1 : (res.data.productGroupRootId == 6 ? 6 : 11);
                var map = $.extend({}, _this.state.info, res.data);
                _this.setState({'info': map});

                //通知物品声明单价
                eventFlux.dispatch(['orders_goods_Event'], {'currencyCode': res.data.currencyCode});

                callback(res.data.productGroupRootId);
            }
        });
    },
    getReceived: function (productUid, callback) {  //根据Uid获取产品主服务或者必须服务是否含揽收。并且可选服务是否为揽收服务
        var _this = this;

        var config = {
            'urlParams': {
                'uid': productUid
            }
        };

        ordersService.hasReceived(config, function (res) {
            if (res.errorCode === 0) {
                var flag = false;
                if (res.data.productReceive) {    //主服务或者必须服务包含揽收服务
                    flag = true;
                } else {
                    var arrSel = _this.state.data.optionalService;
                    arrSel.forEach(function (item, index) {
                        if (item.serviceTypeCode == 'ST001') {    //已选可选服务里有揽收服务
                            flag = true;
                            return;
                        }
                    });
                }
                res.data.isHaveReceive = flag;
                var map = $.extend({}, _this.state.info, res.data);
                _this.setState({'info': map});

                if(typeof callback == 'function'){
                    callback(flag);
                }
            }
        });
    },
    useNewAddress: function (type) {
        var _this = this;

        var transportType = _this.state.info.productGroupRootId;
        transportType = transportType == 1 ? 1 : (transportType == 6 ? 6 : 11);
        //提货地址类型为11
        transportType = type == 3 ? 11 : transportType;

        var config = {
            'urlParams': {
                'type': type,
                'transportType': transportType,
                'uId': _this.state.info.productUid
            }
        };
        ordersService.getAddress(config, function (res) {
            if (res.errorCode === 0) {
                var data = type == 1 ? res.data.send : (type == 2 ? res.data.receiver : res.data.pick);

                var id = type == 1 ? 'from-checkbox' : (type == 2 ? 'to-checkbox' : 'fetch-checkbox');
                if (data && data.length == 10) {
                    $('#' + id).addClass('u-checkbox-disabled');
                } else {
                    $('#' + id).removeClass('u-checkbox-disabled');
                }
            }
        });

        if (type == 1) {  //发件地址
            for (var i in _this.state.data.fromAddress) {
                _this.state.data.fromAddress[i] = '';
            }

            _this.state.data.fromSynShow = true;
            _this.state.data.fromName = '';
            _this.state.data.fromPhone = '';
            _this.state.data.fromTelephone = '';
            _this.state.data.fromDetail = '';
            _this.state.data.fromAddress.transportType = transportType;
            $('#fromAddress-box input.required').removeClass('required');

            if(_this.state.info.from === 'highVolumeOrders') {
                _this.clearErrorTipsByAddrType("fromAddress",1)
            }
        } else if (type == 2) {    //收件地址
            for (var i in _this.state.data.toAddress) {
                _this.state.data.toAddress[i] = '';
            }

            _this.state.data.toSynShow = true;
            _this.state.data.toName = '';
            _this.state.data.toPhone = '';
            _this.state.data.toTelephone = '';
            _this.state.data.toDetail = '';
            _this.state.data.toAddress.transportType = transportType;
            $('#toAddress-box input.required').removeClass('required');
            if(_this.state.info.from === 'highVolumeOrders') {
                _this.clearErrorTipsByAddrType("toAddress",2)
            }
        } else if (type == 3) {    //揽收地址
            for (var i in _this.state.data.fetchAddress) {
                _this.state.data.fetchAddress[i] = '';
            }

            _this.state.data.fetchSynShow = true;
            _this.state.data.fetchName = '';
            _this.state.data.fetchPhone = '';
            _this.state.data.fetchTelephone = '';
            _this.state.data.fetchDetail = '';
            _this.state.data.fetchAddress.transportType = transportType;
            $('#fetchAddress-box input.required').removeClass('required');
            if(_this.state.info.from === 'highVolumeOrders') {
                _this.clearErrorTipsByAddrType("fetchAddress",3)
            }
        }
        _this.setState();    //更新视图
    },
    checked: function (type) {
        var _this = this;

        //判断是否可勾选
        var id = type == 1 ? 'from-checkbox' : (type == 2 ? 'to-checkbox' : 'fetch-checkbox');
        if ($('#' + id).hasClass('u-checkbox-disabled')) {
            return;
        }

        if (type == 1) {
            _this.state.data.fromAddress.syncAddress = !_this.state.data.fromAddress.syncAddress;
        } else if (type == 2) {
            _this.state.data.toAddress.syncAddress = !_this.state.data.toAddress.syncAddress;
        } else if (type == 3) {
            _this.state.data.fetchAddress.syncAddress = !_this.state.data.fetchAddress.syncAddress;
        }

        _this.setState();
    },
    checkPhone: function (type) {
        var _this = this;
        if (type == 1) {
            if ($.trim($('#fromPhone').val()) || $.trim($('#fromTelephone').val())) {
                $('#fromPhone,#fromTelephone').removeClass('required');
                // _this.refs["fromPhone"].hideErrorMsg('');
            }
        } else if (type == 2) {
            if ($.trim($('#toPhone').val()) || $.trim($('#toTelephone').val())) {
                $('#toPhone,#toTelephone').removeClass('required');
                // _this.refs["toPhone"].hideErrorMsg('');
            }
        } else if (type == 3) {
            if ($.trim($('#fetchPhone').val()) || $.trim($('#fetchTelephone').val())) {
                $('#fetchPhone,#fetchTelephone').removeClass('required');
                // _this.refs["fetchPhone"].hideErrorMsg('');
            }
        }
    },
    checkEmail: function (type) {
        var _this = this;
        if (type == 1) {
            if (!$.trim($('#fromEmail').val())) {
                $('#fromEmail').removeClass('required');
            }
        } else if (type == 2) {
            if (!$.trim($('#toEmail').val())) {
                $('#toEmail').removeClass('required');
            }
        } else if (type == 3) {
            if (!$.trim($('#fetchEmail').val())) {
                $('#fetchEmail').removeClass('required');
            }
        }
    },
    getCountry: function (type) {
        var _this = this;

        var id = type == 's' ? 'from-country' : (type == 'e' ? 'to-country' : 'fetch-country');
        selectFactory({
            data: [],
            id: id,
            defaultText: '请选择',
            isSearch: true,
            searchPlaceHoder: '请输入名称或二字码',
            isSaveInputVal: true,
            pagination: true,
            onSearchValueChange: function (attachEle, q, currentPage) {
                var config = {
                    'urlParams': {
                        'id': _this.state.info.productId,
                        'type': type,
                        'q': q || '',
                        'pageIndex': currentPage || 1,
                        'pageSize': 10
                    }
                };
                ordersService.getProductCountry(config, function (res) {
                    if (res.errorCode === 0) {
                        res.data.forEach(function (item, index) {
                            item['name'] += '(' + item['code'] + ')';
                        });
                    }
                    attachEle.setData(res);
                });
            },
            attrTextModel: function (name, data, item) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                _this.state.data[arrdessType].countryName = name;
                _this.state.data[arrdessType].countryCode = item.code || '';

                //清除级联数据
                _this.state.data[arrdessType].provinceName = '';
                _this.state.data[arrdessType].provinceId = '';
                _this.state.data[arrdessType].cityName = '';
                _this.state.data[arrdessType].cityId = '';
                _this.state.data[arrdessType].districtName = '';
                _this.state.data[arrdessType].districtId = '';
                _this.state.data[arrdessType].streetName = '';
                _this.state.data[arrdessType].streetId = '';
                _this.state.data[arrdessType].address = '';
                _this.state.data[arrdessType].transportName = '';
                _this.state.data[arrdessType].transportId = '';

                if (type == 's') {
                    $('#from-country').removeClass('required');
                } else if (type == 'e') {
                    $('#to-country').removeClass('required');
                } else if (type == 'l') {
                    $('#fetch-country').removeClass('required');
                }

                _this.clearAddrErrorTipsByType(arrdessType)

                _this.setState();
            }
        }).open();
    },
    getSeaAir: function (type) {
        var _this = this;

        var id = type == 's' ? 'from-sea-air' : 'to-sea-air';

        selectFactory({
            data: [],
            id: id,
            defaultText: '请选择',
            isSearch: true,
            isSaveInputVal: true,
            pagination: true,
            showTextField: 'name',
            onSearchValueChange: function (attachEle, q, currentPage) {
                var searchPlaceHoder = _this.state.info.productGroupRootId == 1 ? '请输入名称' : '请输入名称或三字码';
                Select.sharePool[id].searchPlaceHoder = searchPlaceHoder;

                var arrdessType = type == 's' ? 'fromAddress' : 'toAddress';
                var countryCode = _this.state.data[arrdessType].countryCode || '';
                if (!countryCode) {
                    return;
                }

                var config = {
                    'urlParams': {
                        'id': _this.state.info.productId,
                        'countryCode': countryCode,
                        'type': type,
                        'q': q || '',
                        'pageIndex': currentPage || 1,
                        'pageSize': 10
                    }
                };
                ordersService.getProductSeaAir(config, function (res) {
                    if (res.errorCode === 0) {
                        res.data.forEach(function (item, index) {
                            if (_this.state.info.productGroupRootId == 1) {    //海运
                                item['name'] += '(' + item['enName'] + ')';
                            } else if (_this.state.info.productGroupRootId == 6) {    //空运
                                item['name'] += '(' + item['code'] + ')';
                            }
                        });
                    }
                    attachEle.setData(res);
                });
            },
            attrTextModel: function (name, data, item) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                _this.state.data[arrdessType].transportName = name;
                _this.state.data[arrdessType].transportId = item.id || '';
                _this.state.data[arrdessType].transportType = _this.state.info.productGroupRootId

                if (type == 's') {
                    $('#from-sea-air').removeClass('required');
                } else if (type == 'e') {
                    $('#to-sea-air').removeClass('required');
                } else if (type == 'l') {
                    $('#fetch-sea-air').removeClass('required');
                }

                _this.setState();
            }
        }).open();
    },
    getOtherCity: function (type) {    //其他国家城市
        var _this = this;

        var id = type == 's' ? 'from-other-city' : (type == 'e' ? 'to-other-city' : 'fetch-other-city');
        selectFactory({
            data: [],
            id: id,
            defaultText: '请选择',
            isSearch: true,
            isSaveInputVal: true,
            pagination: true,
            showTextField: 'cityName',
            onSearchValueChange: function (attachEle, q, currentPage) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                var countryCode = _this.state.data[arrdessType].countryCode || '';
                if (!countryCode) {
                    return;
                }

                var config = {
                    'urlParams': {
                        'id': _this.state.info.productId,
                        'countryCode': countryCode,
                        'type': type,
                        'q': q || '',
                        'pageIndex': currentPage || 1,
                        'pageSize': 10
                    }
                };
                ordersService.getProductCity(config, function (res) {
                    attachEle.setData(res);
                });
            },
            attrTextModel: function (name, data, item) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                _this.state.data[arrdessType].cityName = name;
                _this.state.data[arrdessType].cityId = item.id || '';
                _this.state.data[arrdessType].address = '';

                if (type == 's') {
                    $('#from-other-city').removeClass('required');
                } else if (type == 'e') {
                    $('#to-other-city').removeClass('required');
                } else if (type == 'l') {
                    $('#fetch-other-city').removeClass('required');
                }


                _this.setState();
            }
        }).open();
    },
    getProvince: function (type) {    //中国-省份
        var _this = this;

        var id = type == 's' ? 'from-province' : (type == 'e' ? 'to-province' : 'fetch-province');
        selectFactory({
            data: [],
            id: id,
            defaultText: '请选择',
            defaultCount: 1000,
            isSaveInputVal: true,
            showTextField: 'cityName',
            isCreateNewSelect:true,
            onSearchValueChange: function (attachEle, q, currentPage) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                var countryCode = _this.state.data[arrdessType].countryCode || '';
                if (!countryCode) {
                    return;
                }

                var config = {
                    'urlParams': {
                        'id': _this.state.info.productId,
                        'countryCode': countryCode,
                        'parentId': null,
                        'type': type,
                        'q': q || '',
                        'pageIndex': currentPage || 1,
                        'pageSize': 1000
                    }
                };
                ordersService.getProductCity(config, function (res) {
                    attachEle.setData(res);
                });
            },
            attrTextModel: function (name, data, item) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                _this.state.data[arrdessType].provinceName = name;
                _this.state.data[arrdessType].provinceId = item.id || '';

                //清除级联数据
                _this.state.data[arrdessType].cityName = '';
                _this.state.data[arrdessType].cityId = '';
                _this.state.data[arrdessType].districtName = '';
                _this.state.data[arrdessType].districtId = '';
                _this.state.data[arrdessType].streetName = '';
                _this.state.data[arrdessType].streetId = '';
                _this.state.data[arrdessType].address = '';

                if (type == 's') {
                    $('#from-province').removeClass('required');
                } else if (type == 'e') {
                    $('#to-province').removeClass('required');
                } else if (type == 'l') {
                    $('#fetch-province').removeClass('required');
                }

                _this.setState();
                _this.getCity(type);
            }
        }).open();
    },
    getCity: function (type) {    //中国-城市
        var _this = this;

        var id = type == 's' ? 'from-city' : (type == 'e' ? 'to-city' : 'fetch-city');
        selectFactory({
            data: [],
            id: id,
            defaultText: '请选择',
            defaultCount: 1000,
            isSaveInputVal: true,
            showTextField: 'cityName',
            isCreateNewSelect:true,
            onSearchValueChange: function (attachEle, q, currentPage) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                var countryCode = _this.state.data[arrdessType].countryCode || '',
                    parentId = _this.state.data[arrdessType].provinceId;
                if (!countryCode || !parentId) {
                    return;
                }

                var config = {
                    'urlParams': {
                        'id': _this.state.info.productId,
                        'countryCode': countryCode,
                        'parentId': parentId,
                        'type': type,
                        'q': q || '',
                        'pageIndex': currentPage || 1,
                        'pageSize': 1000
                    }
                };
                ordersService.getProductCity(config, function (res) {
                    attachEle.setData(res);
                });
            },
            attrTextModel: function (name, data, item) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                _this.state.data[arrdessType].cityName = name;
                _this.state.data[arrdessType].cityId = item.id || '';

                //清除级联数据
                _this.state.data[arrdessType].districtName = '';
                _this.state.data[arrdessType].districtId = '';
                _this.state.data[arrdessType].streetName = '';
                _this.state.data[arrdessType].streetId = '';
                _this.state.data[arrdessType].address = '';

                if (type == 's') {
                    $('#from-city').removeClass('required');
                } else if (type == 'e') {
                    $('#to-city').removeClass('required');
                } else if (type == 'l') {
                    $('#fetch-city').removeClass('required');
                }

                _this.setState();

                _this.getArea(type);
            }
        }).open();
    },
    getArea: function (type) {    //中国-区域
        var _this = this;

        var id = type == 's' ? 'from-area' : (type == 'e' ? 'to-area' : 'fetch-area');
        selectFactory({
            data: [],
            id: id,
            defaultText: '请选择',
            defaultCount: 1000,
            isSaveInputVal: true,
            showTextField: 'cityName',
            isCreateNewSelect:true,
            onSearchValueChange: function (attachEle, q, currentPage) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                var countryCode = _this.state.data[arrdessType].countryCode || '',
                    parentId = _this.state.data[arrdessType].cityId;
                if (!countryCode || !parentId) {
                    return;
                }

                var config = {
                    'urlParams': {
                        'id': _this.state.info.productId,
                        'countryCode': countryCode,
                        'parentId': parentId,
                        'type': type,
                        'q': q || '',
                        'pageIndex': currentPage || 1,
                        'pageSize': 1000
                    }
                };
                ordersService.getProductCity(config, function (res) {
                    attachEle.setData(res);
                });
            },
            attrTextModel: function (name, data, item) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                _this.state.data[arrdessType].districtName = name;
                _this.state.data[arrdessType].districtId = item.id || '';

                //清除级联数据
                _this.state.data[arrdessType].streetName = '';
                _this.state.data[arrdessType].streetId = '';
                _this.state.data[arrdessType].address = '';

                if (type == 's') {
                    $('#from-area').removeClass('required');
                } else if (type == 'e') {
                    $('#to-area').removeClass('required');
                } else if (type == 'l') {
                    $('#fetch-area').removeClass('required');
                }

                _this.setState();

                _this.getStreet(type);
            }
        }).open();
    },
    getStreet: function (type) {    //中国-街道
        var _this = this;

        var id = type == 's' ? 'from-street' : (type == 'e' ? 'to-street' : 'fetch-street');
        selectFactory({
            data: [],
            id: id,
            defaultText: '请选择',
            defaultCount: 1000,
            isSaveInputVal: true,
            showTextField: 'cityName',
            isCreateNewSelect:true,
            onSearchValueChange: function (attachEle, q, currentPage) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                var countryCode = _this.state.data[arrdessType].countryCode || '',
                    parentId = _this.state.data[arrdessType].districtId;
                if (!countryCode || !parentId) {
                    return;
                }

                var config = {
                    'urlParams': {
                        'id': _this.state.info.productId,
                        'countryCode': countryCode,
                        'parentId': parentId,
                        'type': type,
                        'q': q || '',
                        'pageIndex': currentPage || 1,
                        'pageSize': 1000
                    }
                };
                ordersService.getProductCity(config, function (res) {
                    attachEle.setData(res);
                });
            },
            attrTextModel: function (name, data, item) {
                var arrdessType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');
                _this.state.data[arrdessType].streetName = name;
                _this.state.data[arrdessType].streetId = item.id || '';

                //清除级联数据
                _this.state.data[arrdessType].address = '';

                if (type == 's') {
                    $('#from-street').removeClass('required');
                } else if (type == 'e') {
                    $('#to-street').removeClass('required');
                } else if (type == 'l') {
                    $('#fetch-street').removeClass('required');
                }

                _this.setState();
            }
        }).open();
    },
    showAddressBook: function (type) {    //展示地址通讯录,type-> 1:发件地址，2:目的地址，3:揽收地址
        var _this = this;

        var transportType = _this.state.info.productGroupRootId;
        transportType = transportType == 1 ? 1 : (transportType == 6 ? 6 : 11);

        //提货地址类型为11
        transportType = type == 3 ? 11 : transportType;

        var title = type == 1 ? '发件地址' : (type == 2 ? '收件地址' : '提货地址');

        var config = {
            'urlParams': {
                'type': type,
                'transportType': transportType,
                'uId': _this.state.info.productUid
            }
        };
        ordersService.getAddress(config, function (res) {
            if (res.errorCode === 0) {
                var list = type == 1 ? res.data.send : (type == 2 ? res.data.receiver : res.data.pick);

                var isHaveDefault = false;
                list.forEach(function(item, index){
                    if(item.isDefault){
                        isHaveDefault = true;
                    }
                });
                _this.setState({
                    'addressbook': {
                        'title': title,
                        'type': type,
                        'isShow': true,
                        'list': list || [],
                        'isHaveDefault':isHaveDefault
                    }
                });
                $('input[name="addressbook"]').attr("checked", false);
            }
        });
    },
    cancelAddressBook: function () {    //取消地址弹出层
        var _this = this;

        _this.state.addressbook.isShow = false;

        _this.setState();
    },
    confirmAddressBook: function () {
        var _this = this;


        var id = $('input[name="addressbook"]:checked').val();

        if (id) {
            var current = null;
            _this.state.addressbook.list.forEach(function (item, index) {
                if (item.id == id) {
                    current = item;
                    return;
                }
            });

            if (current) {    //将值赋值给this.state.data[addressType]
                var addressType = _this.state.addressbook.type == 1 ? 'fromAddress' : (_this.state.addressbook.type == 2 ? 'toAddress' : 'fetchAddress');

                _this.state.data[addressType] = $.extend({}, current);
                _this.state.data[addressType].syncAddress = false;

                _this.state.data[addressType].countryName += '(' + _this.state.data[addressType].countryCode + ')';
                _this.state.data[addressType].transportName += '(' + _this.state.data[addressType].transportCode + ')';

                if (_this.state.addressbook.type == 1) {
                    _this.state.data.fromName = current.name;
                    _this.state.data.fromPhone = current.phone;
                    _this.state.data.fromTelephone = current.telPhone;
                    _this.state.data.fromSynShow = true;
                    $('#fromAddress-box input.required').removeClass('required');
                    $('#from-checkbox').removeClass('u-checkbox-disabled');

                    if(_this.state.info.from === 'highVolumeOrders') { //清除错误提示
                        _this.clearErrorTipsByAddrType("fromAddress",1)
                    }
                } else if (_this.state.addressbook.type == 2) {
                    _this.state.data.toName = current.name;
                    _this.state.data.toPhone = current.phone;
                    _this.state.data.toTelephone = current.telPhone;
                    _this.state.data.toSynShow = true;
                    $('#toAddress-box input.required').removeClass('required');
                    $('#to-checkbox').removeClass('u-checkbox-disabled');

                    if(_this.state.info.from === 'highVolumeOrders') { //清除错误提示
                        _this.clearErrorTipsByAddrType("toAddress",2)
                    }
                } else if (_this.state.addressbook.type == 3) {
                    _this.state.data.fetchName = current.name;
                    _this.state.data.fetchPhone = current.phone;
                    _this.state.data.fetchTelephone = current.telPhone;
                    _this.state.data.fetchSynShow = true;
                    $('#fetchAddress-box input.required').removeClass('required');
                    $('#fetch-checkbox').removeClass('u-checkbox-disabled');

                    if(_this.state.info.from === 'highVolumeOrders') { //清除错误提示
                        _this.clearErrorTipsByAddrType("fetchAddress",3)
                    }
                }
            }
        }

        _this.state.addressbook.isShow = false;    //关闭弹出层

        _this.setState();
    },
    changeVal: function (id, type, nodes) {
        var _this = this;

        var value = $.trim($('#' + id).val());
        var addressType = type == 's' ? 'fromAddress' : (type == 'e' ? 'toAddress' : 'fetchAddress');

        _this.state.data[addressType][nodes] = value;

        $('#' + id).removeClass('required');

        _this.setState();
    },
    getData: function (callback) {    //父组件里面调用该方法，进行数据校验、保存
        var _this = this;
        var ret = false, isOk = true;

        var nameReg = /^([\w\u4E00-\u9FA5_\-\s]+)+$/,   //名称校验
            phoneReg = /^([\d_\-\+]+)+$/,    //电话校验
            emailReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,    //邮箱校验
            postReg = /^[0-9a-zA-Z]*$/;    //邮编校验

        var val = _this.state.data;

        var isSeaAir = _this.state.info.productGroupRootId == 11 ? false : true,
            isHaveReceive = _this.state.info.isHaveReceive ? true : false;

        // 发件地校验
        if (!$.trim(val.fromName) || !nameReg.test(val.fromName)) {    //名称校验
            $('#fromName').addClass('required');
            isOk = false;
        }
        if (!$.trim(val.fromAddress.postcode) || !postReg.test(val.fromAddress.postcode)) {    //邮编校验
            $('#fromPostcode').addClass('required');
            isOk = false;
        }
        if ($.trim(val.fromAddress.email) && !emailReg.test(val.fromAddress.email)) {    //电子邮箱校验
            $('#fromEmail').addClass('required');
            isOk = false;
        }
        val.fromPhone = $.trim(val.fromPhone);
        val.fromTelephone = $.trim(val.fromTelephone);

        if (!$.trim(val.fromPhone) && !$.trim(val.fromTelephone)) {
            $('#fromPhone').addClass('required');
            isOk = false;
        }
        if ($.trim(val.fromPhone) && !phoneReg.test(val.fromPhone)) {
            $('#fromPhone').addClass('required');
            isOk = false;
        }
        if ($.trim(val.fromTelephone) && !phoneReg.test(val.fromTelephone)) {
            $('#fromTelephone').addClass('required');
            isOk = false;
        }

        // 收件地校验
        if (!$.trim(val.toName) || !nameReg.test(val.toName)) {    //名称校验
            $('#toName').addClass('required');
            isOk = false;
        }
        if (!$.trim(val.toAddress.postcode) || !postReg.test(val.toAddress.postcode)) {    //邮编校验
            $('#toPostcode').addClass('required');
            isOk = false;
        }
        if ($.trim(val.toAddress.email) && !emailReg.test(val.toAddress.email)) {    //电子邮箱校验
            $('#toEmail').addClass('required');
            isOk = false;
        }
        val.toPhone = $.trim(val.toPhone);
        val.toTelephone = $.trim(val.toTelephone);

        if (!$.trim(val.toPhone) && !$.trim(val.toTelephone)) {
            $('#toPhone').addClass('required');
            isOk = false;
        }
        if ($.trim(val.toPhone) && !phoneReg.test(val.toPhone)) {
            $('#toPhone').addClass('required');
            isOk = false;
        }
        if ($.trim(val.toTelephone) && !phoneReg.test(val.toTelephone)) {
            $('#toTelephone').addClass('required');
            isOk = false;
        }

        if (isHaveReceive) {
            // 提货地址校验
            if (!$.trim(val.fetchName) || !nameReg.test(val.fetchName)) {    //名称校验
                $('#fetchName').addClass('required');
                isOk = false;
            }
            if (!$.trim(val.fetchAddress.postcode) || !postReg.test(val.fetchAddress.postcode)) {    //邮编校验
                $('#fetchPostcode').addClass('required');
                isOk = false;
            }
            if ($.trim(val.fetchAddress.email) && !emailReg.test(val.fetchAddress.email)) {    //电子邮箱校验
                $('#fetchEmail').addClass('required');
                isOk = false;
            }

            val.fetchPhone = $.trim(val.fetchPhone);
            val.fetchTelephone = $.trim(val.fetchTelephone);

            if (!$.trim(val.fetchPhone) && !$.trim(val.fetchTelephone)) {
                $('#fetchPhone').addClass('required');
                isOk = false;
            }
            if ($.trim(val.fetchPhone) && !phoneReg.test(val.fetchPhone)) {
                $('#fetchPhone').addClass('required');
                isOk = false;
            }
            if ($.trim(val.fetchTelephone) && !phoneReg.test(val.fetchTelephone)) {
                $('#fetchTelephone').addClass('required');
                isOk = false;
            }
        }

        //校验国家
        if (!$('#from-country').val()) {
            $('#from-country').addClass('required');
            isOk = false;
        }
        if (!$('#to-country').val()) {
            $('#to-country').addClass('required');
            isOk = false;
        }
        if (isHaveReceive) {
            if (!$('#fetch-country').val()) {
                $('#fetch-country').addClass('required');
                isOk = false;
            }
        }
        if (isSeaAir) {    // 海运或空运
            if (!$('#from-sea-air').val()) {
                $('#from-sea-air').addClass('required');
                isOk = false;
            }
            if (!$('#to-sea-air').val()) {
                $('#to-sea-air').addClass('required');
                isOk = false;
            }
        } else {
            if (!$('#fromAddress').val()) {
                $('#fromAddress').addClass('required');
                isOk = false;
            }
            if (!$('#toAddress').val()) {
                $('#toAddress').addClass('required');
                isOk = false;
            }

            if (val.fromAddress.countryCode == 'CN') {
                if (!$('#from-province').val()) {
                    $('#from-province').addClass('required');
                    isOk = false;
                }
                if (!$('#from-city').val()) {
                    $('#from-city').addClass('required');
                    isOk = false;
                }
            } else {
                if (!$('#from-other-city').val()) {
                    $('#from-other-city').addClass('required');
                    isOk = false;
                }
            }
            if (val.toAddress.countryCode == 'CN') {
                if (!$('#to-province').val()) {
                    $('#to-province').addClass('required');
                    isOk = false;
                }
                if (!$('#to-city').val()) {
                    $('#to-city').addClass('required');
                    isOk = false;
                }
            } else {
                if (!$('#to-other-city').val()) {
                    $('#to-other-city').addClass('required');
                    isOk = false;
                }
            }
        }

        if (isHaveReceive) {
            if (!$('#fetchAddress').val()) {
                $('#fetchAddress').addClass('required');
                isOk = false;
            }

            if (val.fetchAddress.countryCode == 'CN') {
                if (!$('#fetch-province').val()) {
                    $('#fetch-province').addClass('required');
                    isOk = false;
                }
                if (!$('#fetch-city').val()) {
                    $('#fetch-city').addClass('required');
                    isOk = false;
                }
            } else {
                if (!$('#fetch-other-city').val()) {
                    $('#fetch-other-city').addClass('required');
                    isOk = false;
                }
            }
        }

        if (isOk) {
            ret = $.extend({}, _this.state.data);
            ret.isHaveReceive = true;
            ret.productGroupRootId = _this.state.info.productGroupRootId;
        } else {
            ret = false;
        }
        if (!_this.state.info.isHaveReceive && isOk) {    //不包含揽收服务
            ret.fetchName = '';
            ret.fetchPhone = '';
            ret.fetchTelephone = '';
            ret.fetchAddress = {};
            ret.isHaveReceive = false;
        }
        callback(ret);
    },
    render: function () {
        var _this = this;
        var data = this.state.data || {'fromAddress': {}, 'toAddress': {}, 'fetchAddress': {}},    //保存订单地址数据
            info = this.state.info || {},    //保存订单产品公共数据
            addressbook = this.state.addressbook || {};    //保存地址通讯录数据

        return ~address;
    }
});
module.exports = AddressComponent;